deferred class IUP_WIDGET_TEXT_CARET
-- Commands to handle the attributes related with caret.

inherit
	IUP_WIDGET_INTERNALS
	
insert
	IUP_INTERFACE

feature {ANY}

	set_caret (pos: INTEGER)
		-- (non inheritable): Character position of the insertion point.
		-- The first position is "1". When pos is greater than the number of 
		-- characters in the given line, the caret is placed after the last 
		-- character of the line.
		-- In Windows, if the element does not have the focus the returned value 
		-- is the position of the first character of the current selection. The 
		-- caret is only displayed if the element has the keyboard focus, but its 
		-- position can be changed even if not visible. When changed it will also 
		-- change the selection.
		-- See the Notes above if using UTF-8 strings in GTK.
		require
			pos > 0
		do
			iup_open.set_attribute(Current, "CARET", pos.to_string)
		end

	get_caret: INTEGER
		-- The caret.
		local
			str: STRING
		do
			str := iup_open.get_attribute(Current, "CARET")

			if str.is_integer then
				Result := str.to_integer
			end
		end

	set_caret_pos (pos: INTEGER)
		-- (non inheritable): Also the character position of the insertion point, 
		-- but using a zero based character unique index "pos". Useful for 
		-- indexing the VALUE string. See the Notes below if using UTF-8 strings 
		-- in GTK.
		require
			pos > 0
		do
			iup_open.set_attribute(Current, "CARETPOS", pos.to_string)
		end

	get_caret_pos: INTEGER
		-- The caret position.
		local
			str: STRING
		do
			str := iup_open.get_attribute(Current, "CARETPOS")

			if str.is_integer then
				Result := str.to_integer
			end
		end

end

-- The MIT License (MIT)

-- Copyright (c) 2016, 2017, 2019 by German A. Arias

-- Permission is hereby granted, free of charge, to any person obtaining a copy
-- of this software and associated documentation files (the "Software"), to deal
-- in the Software without restriction, including without limitation the rights
-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-- copies of the Software, and to permit persons to whom the Software is
-- furnished to do so, subject to the following conditions:
--
-- The above copyright notice and this permission notice shall be included in 
-- all copies or substantial portions of the Software.
--
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-- SOFTWARE.
